package com.ruoyi.project.sale.customer.service;
/*test*/
import com.ruoyi.common.utils.security.ShiroUtils;
import com.ruoyi.project.sale.customer.domain.Customer;
import com.ruoyi.project.sale.customer.mapper.CustomerMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class CustomerServiceImpl implements CustomerService {
    @Autowired
    private CustomerMapper customerMapper;
    //查询所有
    @Override
    public List<Customer> findAll(Customer customer) {
        return customerMapper.selectAll(customer);
    }

    //添加
    @Override
    public Integer saveCustomer(Customer customer) {

        return customerMapper.insertCustomer(customer);
    }

    //查询指定id
    @Override
    public Customer findOne(Integer cid) {
        return customerMapper.selectOne(cid);
    }

    //修改的操作
    @Override
    public Integer change(Customer customer) {
        return customerMapper.updateCustomer(customer);
    }

    //单条删除
    @Override
    public Integer removeCustomer(Integer cid) {
        return customerMapper.deleteCustomer(cid);
    }   //返回值是1

    //多条删除
    @Override
    public Integer removeCustomers(Integer[] cids) {

        Integer index = customerMapper.deleteCustomers(cids);
        if (index==cids.length){     //返回值是3，说明删除多条
            return 1;                //说明删除成功
        }

        return 0;
    }


}
